<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <link href="style/css.css" rel="stylesheet" type="text/css" />
    <link href="style/gysqy.css" rel="stylesheet" type="text/css" />
    <link href="style/product_top.css" rel="stylesheet" type="text/css" />
    <script src="lib/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="lib/json2.js" type="text/javascript"></script>
    <script src="lib/jsmart.js" type="text/javascript"></script>
    <script src="script/app.js" type="text/javascript"></script>
    <script src="script/urledit.js" type="text/javascript"></script>
    <script id="supplier" type="text/x-jsmart-tmpl">  
	{foreach $rows as $name => $supplier}
		<li>
			<div class="fl gysqy_lb_tp">
				<img src="/Resources/newImgs/gys/gysqy_pic01.jpg" width="122" height="120" /></div>
			<div class="fl gysqy_lb_nr">
				<div class="gysqy_lb_title">
					<a style="_line-height: 18px;" href="/Manufacturer/Index?mId=8176" title="{$supplier.value}"
						target="_blank">{$supplier.value}公司</a></div>
				<div class="gysqy_lb_wz">
				</div>
				<div class="gysqy_lb_lx" title="类型：销售商  主营产品: 水泵、风机">
					类型：销售商 主营产品: 水泵、风机</div>
				<div class="gysqy_lb_dz">
					地址：上海市闵行区七宝镇九星市场九区1幢1-3号</div>
			</div>
			<div class="fl gysqy_lb_an">
				<a href="/Manufacturer/Index?mId=8176" title="上海企翔泵业有限公司" target="_blank">
					<img src="/Resources/newImgs/product_top/lxsj.png" width="92" height="28" border="0" /></a>
			</div>
		</li>
	{/foreach}
    </script>
    <script id="supplierpage" type="text/x-jsmart-tmpl">
		<a href="{$prev}">上一页</a>                    	                    	
        <a href="{$next}">下一页</a>
	</script>
</head>
<body>
    <center>
        <div id="box">
            <div class="left fl">
                <div class="gys">
                    <form>
                    <div class="gys_textbox fl">
                        <input name="" type="text" class="gys_wbk" id="keyM" /></div>
                    <div class="fl">
                        <a href="#" class="btnManufacturerSearch1">
                            <img src="resources/img/cz_an.jpg" width="100" height="33" border="0" /></a></div>
                    </form>
                </div>
                <!-- gysqy_lb -->
                <div class="gysqy">
                    <div class="gysqy_title">
                        <div class="fl gys_name">
                            供应商</div>
                        <div class="fl record">
                            共 条记录</div>
                    </div>
                    <div class="gysqy_lb">
                        <ul id="supplierlist">
                        </ul>
                    </div>
                    <div style="clear:both;text-align:center;" id="page">

                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">

            $(document).ready(
			function () {
				var myurl=new UrlEdit.URL(decodeURI(document.URL));
				var startkey = myurl.get("startkey");
				var startkey_docid = myurl.get("startkey_docid");
				var endkey = myurl.get("endkey");
				var endkey_docid = myurl.get("endkey_docid");
				var skip = myurl.get("skip");
				var limit = myurl.get("limit");
				
				var parameter = "";
				if (limit != undefined)
					parameter = parameter + "&limit=" + limit;
				else
					parameter = parameter + "&limit=" + 10;		
					
				if (startkey != undefined)
					parameter = parameter + "&startkey=" + startkey;
				if (skip != undefined)
					parameter = parameter + "&skip=" + skip;
				if (startkey_docid != undefined)
					parameter = parameter + "&startkey_docid=" + startkey_docid;
				if (endkey != undefined)
					parameter = parameter + "&endkey=" + endkey;
				if (endkey_docid != undefined)
					parameter = parameter + "&endkey_docid=" + endkey_docid;
								
			    $.ajax({
			        url: path + '/getSupplier?reduce=false' + parameter,
			        type: 'GET',
			        dataType: 'json',
			        success: function (data) {
			            var tpl = new jSmart(document.getElementById('supplier').innerHTML);
			            var res = tpl.fetch(data);
			            $("#supplierlist").html(res);
						
						tpl = new jSmart(document.getElementById('supplierpage').innerHTML);
						var current = data.rows[data.rows.length-1];
						page = new Array();
						
						myurl.remove("endkey");
						myurl.remove("endkey_docid");
						myurl.remove("skip");
						myurl.set("startkey", "\"" + current.key + "\"");
						myurl.set("startkey_docid", current.id);
						myurl.set("skip", 1);
						page.next = encodeURI(myurl.url());
						
						myurl.remove("startkey");
						myurl.remove("startkey_docid");
						myurl.remove("skip");
						myurl.set("endkey", "\"" + current.key + "\"");
						myurl.set("endkey_docid", current.id);
						page.prev = encodeURI(myurl.url());
			            res = tpl.fetch(page);
			            $("#page").html(res);
			        }
			    });
			}
		);
        </script>
    </center>
</body>
</html>
